package com.framework.Module.system.users;

import com.framework.Table.Table;
import com.framerock.baselib.CDate;
import com.framerock.baselib.Jiami;
import com.framerock.baselib.Rock;


public class Tableusers extends Table {


    protected void initTable() {
        this.tablename   = "users";
        this.tablenamesm = "平台用户";

        this.flowsetMap  = Rock.getMap(new String[]{
                "type", "系统",
                "sort", "904",
                "isxt", "1",
        });

        this.addfields("name", "varchar(50)", "", "姓名", new String[]{
                "isbt","1",
                "isss","1"
        });
        this.addfields("user", "varchar(50)", "", "帐号", new String[]{
                "isonly","1",
                "isbt","1",
                "isss","1"
        });
        this.addfields("pass", "varchar(50)", "", "密码@@新增默认123456编辑时不设置不修改", new String[]{
                "islb","0",
                "isss", "0",
                "iszs", "0",
        });
        this.addfields("rand", "varchar(20)", "", "随机数@@用于密码加密", new String[]{
                "notelement", "1",
        });
        this.addfields("mobile", "varchar(20)", "", "手机号", new String[]{
                "isss", "1",
                "isbt","1",
                "isonly","1",
                "attr","mobile",
        });
        this.addfields("face", "varchar(300)", "", "头像", new String[]{
                "fieldstype","uploadimg"
        });
        this.addfields("ranking", "varchar(50)", "", "职位", new String[]{
                "isss","1"
        });
        this.addfields("status", "tinyint(1)", "1", "状态@@启用用户", new String[]{
                "isss","1"
        });
        this.addfields("type", "tinyint(1)", "0", "级别@0|普通,1|管理员,2|超级管理员", new String[]{
                "isss","1"
        });
        this.addfields("sort", "int(11)", "0", "排序号", new String[]{
                "ispx","1",
                "iseditlx","2"
        });
        this.addfields("loginci", "int(11)", "0", "登录数", new String[]{
                "islu","0",
                "ispx","1",
        });
        this.addfields("adddt", "datetime", null, "添加时间", new String[]{
                "islu","0",
                "islb","0",
                "ispx","1",
        });
        this.addfields("dcid", "int(11)", "0", "默认单位", new String[]{
                "islu","0"
        });
        this.addfields("id", "int(11)", "0", "ID");
        this.addfields("user", "UNIQUE KEY", "`user`", "主键user");
    }

    //创建默认管理员
    protected void firstInsert() {
        int count = this.nDb.getCount(this.tablenameal, "`id`>0");
        if(count==0) {
            String rand = CDate.gettime();
            this.nDb.insertbo(this.tablenameal, Rock.getMap(new String[]{
                    "user", "admin",
                    "name", "管理员",
                    "type", "2",
                    "mobile","15800000001",
                    "rand", rand,
                    "face", "https://xinhu-1251238447.file.myqcloud.com/file/face.jpg",
                    "pass", Jiami.md5("123456"+rand),
                    "adddt", CDate.now(),
                    "dcid","1",
                    "dcid", "1"
            }));
        }
    }
}
